package asteroids.expressions;

import java.util.*;

import asteroids.types.*;

public abstract class EntityExpression extends UnaryExpression {

	protected EntityExpression(int line, int column, Expression expression) {
		super(line, column, expression);
	}
	
	@Override
	public List<String> getTypeCheckErrorsExpressions(List<String> typeErrors, Map<String, Type> globals) {
		if(getExpression() != null && getExpression().evaluate(null, globals).getClass() != EntityType.class) {
			typeErrors.add("Line: " + getLine() + " Column: " + getColumn() + " - The expression, " + getExpression().toString() + " is not a space entity.");
			typeErrors = getExpression().getTypeCheckErrorsExpressions(typeErrors, globals);
		}
		return typeErrors;
	}

}
